package package06章_面向对象编程_基础._05oop.exer1_methodMore._03_valueTransfer;

/**
 * @ClassName: e_6_10valueTransferTest
 * @Author 86132
 * @Package package06章_面向对象编程_基础.oop05.exer1_methodMore._03_valueTransfer
 * @Date 2024/2/13 11:34
 * @description:
 */
public class e_6_10valueTransferTest3 {
    public static void main(String[] args) {
        e_6_10valueTransferTest3 test = new e_6_10valueTransferTest3();

        Data data = new Data();
        data.m = 10;
        data.n = 20;


        System.out.println("m = " + data.m + ", n = " + data.n);

        //操作1：
//        int temp = data.m ;
//        data.m = data.n;
//        data.n = temp;

        //操作2：
        test.swap(data);
        System.out.println("m = " + data.m + ", n = " + data.n);
    }

    public void swap(Data data) {
        int temp = data.m;
        data.m = data.n;
        data.n = temp;
    }
}

class Data {
    int m;
    int n;
}